#include <cstdio>

bool visit[ 40000001 ];

int main( )
{
    int i, j;
    for ( i = 13; i <= 40000000; i += 2 )
    {
        if ( i % 3 == 0 || i % 5 == 0 || i % 7 == 0 || i % 11 == 0 || i % 13 == 0 )
            continue;
        if ( !visit[ i ] )
            for ( j = i * 3; j <= 40000000; j += i * 2 )
                visit[ j ] = true;
    }
    for ( i = 30000001; i <= 40000000; i += 2 )
    {
        if ( i % 3 == 0 || i % 5 == 0 || i % 7 == 0 || i % 11 == 0 || i % 13 == 0 )
            continue;
        if ( !visit[ i ] )
            printf("%d\n", i);
    }
    return 0;
}
